//
//  AccountDetailTableViewCell.m
//  UcarTest
//
//  Created by 陈曦 on 16/3/16.
//  Copyright © 2016年 chenxi. All rights reserved.
//

#import "AccountDetailTableViewCell.h"
#import "Define.h"

@implementation AccountDetailTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        //添加背景色
        self.backgroundColor = [UIColor whiteColor];
        
        //备注标签
        self.remarkLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, kScreenWidth / 3 * 2 - 30, 30)];
        self.remarkLabel.numberOfLines = 0;
        self.remarkLabel.lineBreakMode = NSLineBreakByWordWrapping;
        self.remarkLabel.textAlignment = NSTextAlignmentLeft;
        self.remarkLabel.textColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:1];
        self.remarkLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.remarkLabel];

        //时间标签
        self.add_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 120, 10, 110, 30)];
        self.add_timeLabel.textColor = [UIColor colorWithRed:137 / 255.0 green:137 / 255.0 blue:137 / 255.0 alpha:1];
        self.add_timeLabel.font = [UIFont systemFontOfSize:12];
        self.add_timeLabel.textAlignment = NSTextAlignmentRight;
        [self addSubview:self.add_timeLabel];
        
        //金钱标签
        self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 120, 45, 110, 15)];
        self.moneyLabel.textColor = [UIColor colorWithRed:137 / 255.0 green:137 / 255.0 blue:137 / 255.0 alpha:1];
        self.moneyLabel.textAlignment = NSTextAlignmentRight;
        self.moneyLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.moneyLabel];
        
        
    }
    
    return self;
    
}


- (void)setModel:(AccountDetailModel *)model{
    
    _model = model;
    
    _remarkLabel.text = model.remark;
    
    NSDate *confromTimesp1 = [NSDate dateWithTimeIntervalSince1970:[model.add_time intValue]];
    NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc]init];
    [dateFormat1 setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *end_time = [dateFormat1 stringFromDate:confromTimesp1];
    
    _add_timeLabel.text = end_time;
    
    _moneyLabel.text = model.money;
    
}

@end
